<template>
<div class="dy-main EAccountApproveFailed">
  <div class="dy-header">
    <x-header :right-options="{showMore: false}" :left-options="{preventGoBack: true,backText: ''}" @on-click-back="back" @on-click-more="showMenus = true">身份认证</x-header>
  </div>
  <div class="dy-body">
    <div class="IdPhoto">
            <div class="line">
              <div class="bg">
                <img src="../../assets/img/EAccount/photo.png" alt="">
              </div>
            </div>
            <p>认证失败显示错误信息</p>
        </div>
        <div class="IdPhoto">
            <div class="line">
              <div class="bg">
                <img src="../../assets/img/EAccount/photo.png" alt="">
              </div>
            </div>
            <p>认证失败显示错误信息</p>
        </div>
        <group>
          <cell title="姓名" :value="requestData.cardHolder" class="cell"></cell>
          <cell title="身份证" :value="requestData.IDNo" class="cell"></cell>
          <cell title="有效日期" :value="requestData.IDtime" class="cell"></cell>
        </group>
        <div class="btn">
          <flexbox>
            <flexbox-item><x-button type="primary"  @click.native='Done'>完成</x-button></flexbox-item>
            <flexbox-item><x-button type="primary"  @click.native='Again'>重新认证</x-button></flexbox-item>
        </flexbox>
        </div>
  </div>
</div>
</template>

<script>

export default{
  data () {
    return {
      secondAccount: '开通Ⅱ类账户',
      thridAccount: '开通Ⅲ类账户',
      AccountSearch: 'Ⅱ/Ⅲ类账户查询',
      downPop: false, // 控制底部弹层
      requestData: { // 请求报文
        cardHolder: '王大炮', // 持卡人姓名
        IDType: '身份证', // 证件类型
        IDNo: '30344949494944949494', // 身份证号
        IDtime: '2018-2-28' // 有效期限
      },
      returnData: {}, // 返回报文
      done: 1, // 完成按钮
      again: 1 // 重新认证按钮
    }
  },
  mounted () {
    this.requestData.cardHolder = this.$router.query.returnData.name
    this.requestData.IDNo = this.$router.query.returnData.id
    this.requestData.IDtime = this.$router.query.returnData.validity
  },
  methods: {
    back () {
      this.$publicFun.goBack(this)
    },
    Done: function () {
      this.done === 1 ? this.done = 0 : this.done = 1
      if (this.returnData.status) {
        this.getData()
        this.$router.push({name: 'EAccountEnter'})
      } else {
        // todo 如果失败
      }
    },
    Again: function () {
      this.again === 1 ? this.again = 0 : this.again = 1
      this.$router.push({name: 'EAccountApprove'})
    },
    getData () {
      // let _this = this
      this.$bridge.callhandler('nativeRequest',
        JSON.stringify({
          'requstSource': 'internetRequest',
          'url': 'mstep.do?act=business',
          'params': {'method_Name': 'CI008001', 'basic_Data': {cardHolder: '王大炮', IDType: '身份证', IDNo: '30344949494944949494', IDtime: '2018-2-28'}}
        }),
        function (response) {
          response = JSON.parse(response)
          if (response.status === 0 || response.status === '0') {
            // _this.returnData = response.data.data[0]
          } else {
            console.log('fail')
          }
        })
    }
  }
}
</script>

<style lang="less">
  .EAccountApproveFailed{
    .btn{
      margin-top: .3rem;
      padding: 0 .3rem;
    }
    .IdPhoto{
      box-sizing: border-box;
      width: 5.8rem;
      height: 3.4rem;
      margin: .28rem auto;
      padding: 0.29rem 0.55rem;
      background: white;
      p{
        text-align: center;
        padding-top: .26rem;
        font-size: .26rem;
      }
      .line{
        height: 2.3rem;
        border: 1px solid #ccc;
      }
      .bg{
        background: #fafafa;
        margin: .21rem;
        height: 1.87rem;
        text-align: center;
        padding-top: .44rem;
        &>img{
          width: 1.1rem;
          height: 0.99rem;
        }
      }
    }
  }
</style>
